package app.agent.systems

import im.mange.jetboot._
import Html._
import Css._
import im.mange.jetboot.bootstrap3.Bootstrap
import Bootstrap._

case class AddSystemAgent() extends Renderable {
  private val holder = div("addSystemAgent", editor).classes("hidden")

  def render = holder.render
  def show = holder.show
  def hide = holder.hide

 //TODO: should probably have the add button presentation elsewhere
  private def editor =
    Composite(
      nameEditor.styles(marginBottom("5px")),//.classes(colLg12),
      div(
        div(aliasEditor).classes(colLg6),
        div(envEditor).classes(colLg6)
      ).classes(row),
      urlEditor.styles(marginTop("5px"))
    )

  //TODO: there is definitely a form builder in here ...
  //TODO: make instance of Button
  private def urlEditor =
    div(
      span("Url").classes(inputGroupAddon),
      AddSystemTextBox().classes(formControl),
      span(
        R(<button class="btn btn-default" type="button">
          {span().classes(glyphicon("plus")).render}
        </button>)
      ).classes(inputGroupBtn)
    ).classes(inputGroup, inputGroupSm)

  //TODO: de-dupe
  //TODO: make instance of TextBox
  private def envEditor =
    div(
      R(<input type="text" class="form-control"/>),
      span("Env").classes(inputGroupAddon)
    ).classes(inputGroup, inputGroupSm)

  //TODO: de-dupe
  //TODO: make instance of TextBox
  private def aliasEditor =
    div(
      span("Alias").classes(inputGroupAddon),
      R(<input type="text" class="form-control"/>)
    ).classes(inputGroup, inputGroupSm)

  //TODO: de-dupe
  //TODO: make instance of TextBox
  private def nameEditor =
    div(
      span("Name").classes(inputGroupAddon),
      R(<input type="text" class="form-control"/>)
    ).classes(inputGroup, inputGroupSm)
}
